/* StringIdentifiers.java
 * 
 * Alfred Olschnoegger
 * 03.06.2008
 */

package application.parser;

import java.util.HashMap;

/**
 * TODO description
 *
 * @date 03.06.2008
 * @author Alfred Olschnoegger
 */

public class StringIdentifier {
	//instance
	private static StringIdentifier s_Instance;
	
	// parser settings
	private char m_RecordSeperator = ';';
	private char m_FieldSeperator = ',';
	private char m_SuccessValue = '+';
	private char m_ExceptionValue = '!';
	private char m_InformationValue = '#';
	private char m_DataValue = '%';
	
	// Used to map the classes to their specific identifier
	private HashMap<String,String> m_ClassIdentifier;
	private HashMap<String,Integer> m_ExceptionIdentifier;
	
	{
		m_ClassIdentifier = new HashMap<String,String>();
		
		m_ClassIdentifier.put("Rabbit", "r");
		m_ClassIdentifier.put("Hunter", "h");
		m_ClassIdentifier.put("Powerup", "p");
		m_ClassIdentifier.put("Action", "a");
		m_ClassIdentifier.put("AuthKey", "auth");
		m_ClassIdentifier.put("Game", "g");
		m_ClassIdentifier.put("ServerInfoProvider", "i");
		
		m_ExceptionIdentifier = new HashMap<String,Integer>();
		
		m_ExceptionIdentifier.put("GameNotExistingException",1);
		m_ExceptionIdentifier.put("GameEndedException",2);
		m_ExceptionIdentifier.put("NotLoggedInException",3);
		m_ExceptionIdentifier.put("UserAlreadyRegisteredException",4);
		m_ExceptionIdentifier.put("HunterNotRegisteredException",5);
		m_ExceptionIdentifier.put("ObjectNotFoundException", 6);
	}

	public static StringIdentifier getInstance() {
		if(s_Instance == null)
			s_Instance = new StringIdentifier();
		return s_Instance;
	}
	
	private StringIdentifier() {}
	


	public char getRecordSeperator() {
		return m_RecordSeperator;
	}

	public char getFieldSeperator() {
		return m_FieldSeperator;
	}

	public char getSuccessValue() {
		return m_SuccessValue;
	}

	public char getExceptionValue() {
		return m_ExceptionValue;
	}

	public char getInformationValue() {
		return m_InformationValue;
	}
	
	public char getDataValue() {
		return m_DataValue;
	}

	public String getClassIdent(String ident) {
		return m_ClassIdentifier.get(ident);
	}
	
	public int getExceptionIdent(String ident) {
		return m_ExceptionIdentifier.get(ident);
	}
	
	public boolean containsClassKey(Object key) {
		return m_ClassIdentifier.containsKey(key);
	}
	
	public boolean containsExceptionKey(Object key) {
		return m_ExceptionIdentifier.containsKey(key);
	}
	
}


// end of StringIdentifiers.java
